package com.qf.util;

import java.io.IOException;
import java.util.Properties;

public class PropertiesUtils {
    //创建一个私有的Proper静态成员--类加载时，就去读取。properties

    private  static Properties properties = new Properties();

    //静态代码块--PropertiesUtils类被类加载器加载时触发
    //1.在一个JVN进程中，静态块只会被触发一次

    static {
        try {
            properties.load(PropertiesUtils.class.getClassLoader().getResourceAsStream("application.properties"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public  static  String getProperties(String key){
        return  properties.getProperty(key);
    }
    public static  void main(String[] args){
        String value =PropertiesUtils.getProperties("nologin");
        System.out.println(value);
    }
}
